From: Keir Fraser Date: Thu, 1 Apr 2010 08:47:49 +0000 (+0100) Subject: hvm: merge efer check X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12451 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=3ccd588bf130739bf35ea34cbfa52d2e10db5b00;p=xen.git hvm: merge efer check Signed-off-by: Christoph Egger Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 216f818f1c..4029ea8442 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -583,6 +583,16 @@ static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) return 0; } +static bool_t hvm_efer_valid(uint64_t value, uint64_t efer_validbits) +{ + return !((value & ~efer_validbits) || + ((sizeof(long) != 8) && (value & EFER_LME)) || + (!cpu_has_nx && (value & EFER_NX)) || + (!cpu_has_syscall && (value & EFER_SCE)) || + (!cpu_has_ffxsr && (value & EFER_FFXSE)) || + ((value & (EFER_LME|EFER_LMA)) == EFER_LMA)); +} + static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) { int vcpuid, rc; @@ -629,13 +639,8 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) return -EINVAL; } - if ( (ctxt.msr_efer & ~(EFER_FFXSE | EFER_LME | EFER_LMA | - EFER_NX | EFER_SCE)) || - ((sizeof(long) != 8) && (ctxt.msr_efer & EFER_LME)) || - (!cpu_has_nx && (ctxt.msr_efer & EFER_NX)) || - (!cpu_has_syscall && (ctxt.msr_efer & EFER_SCE)) || - (!cpu_has_ffxsr && (ctxt.msr_efer & EFER_FFXSE)) || - ((ctxt.msr_efer & (EFER_LME|EFER_LMA)) == EFER_LMA) ) + if ( !hvm_efer_valid( + ctxt.msr_efer, EFER_FFXSE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) ) { gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n", ctxt.msr_efer); @@ -984,11 +989,7 @@ int hvm_set_efer(uint64_t value) value &= ~EFER_LMA; - if ( (value & ~(EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE)) || - ((sizeof(long) != 8) && (value & EFER_LME)) || - (!cpu_has_nx && (value & EFER_NX)) || - (!cpu_has_syscall && (value & EFER_SCE)) || - (!cpu_has_ffxsr && (value & EFER_FFXSE)) ) + if ( !hvm_efer_valid(value, EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE) ) { gdprintk(XENLOG_WARNING, "Trying to set reserved bit in " "EFER: %"PRIx64"\n", value);